<?php

namespace App\Common\Services\Date;

class TimerRange
{
    /**
     * 获取今日起始时间戳
     */
    public static function getToday()
    {
        $start_time = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
        $end_time = mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')) - 1;
        return [
            'start_time' => $start_time,
            'end_time' => $end_time
        ];
    }

    /**
     * 获取昨日起始时间戳
     */
    public static function getYesterday()
    {
        $start_time = mktime(0, 0, 0, date('m'), date('d') - 1, date('Y'));
        $end_time = mktime(0, 0, 0, date('m'), date('d'), date('Y')) - 1;
        return [
            'start_time' => $start_time,
            'end_time' => $end_time
        ];
    }
    /**
     * 获取本周起始时间戳
     */
    public static function getThisWeek()
    {
        $start_time = mktime(0, 0, 0, date('m'), date('d') - date('w') + 1, date('Y'));
        $end_time = mktime(23, 59, 59, date('m'), date('d') - date('w') + 7, date('Y'));
        return [
            'start_time' => $start_time,
            'end_time' => $end_time
        ];
    }

    /**
     * 获取本月起始时间戳
     */
    public static function getThisMonth()
    {
        $start_time = mktime(0, 0, 0, date('m'), 1, date('Y'));
        $end_time = mktime(23, 59, 59, date('m'), date('t'), date('Y'));
        return [
            'start_time' => $start_time,
            'end_time' => $end_time
        ];
    }

}
